﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ElectronicWMSA.Comm.Forms.Message
{
    public enum MessageBoxStyle
    {
        warning = 0,
        error = 1,
        enquire = 2,
        right = 3
    };

    public partial class MessageBoxFrm : Form
    {
        public MessageBoxFrm(MessageBoxStyle messageBoxStyle, string msg)
        {
            InitializeComponent();
            if (messageBoxStyle == MessageBoxStyle.warning)
            {
                pictureBox1.Image = global::ElectronicWMSA.Properties.Resources.warning;
                this.Text = " 警告 ";
                panelSure.Visible = true;
                panelQuestion.Visible = false;
            }
            else if (messageBoxStyle == MessageBoxStyle.error)
            {
                pictureBox1.Image = global::ElectronicWMSA.Properties.Resources.error;
                this.Text = " 错误 ";
                panelSure.Visible = false;
                panelQuestion.Visible = true;
            }
            else if (messageBoxStyle == MessageBoxStyle.enquire)
            {
                pictureBox1.Image = global::ElectronicWMSA.Properties.Resources.enquire;
                this.Text = " 询问 ";
                panelSure.Visible = true;
                panelQuestion.Visible = true;
            }
            else if (messageBoxStyle == MessageBoxStyle.right)
            {
                pictureBox1.Image = global::ElectronicWMSA.Properties.Resources.right;
                this.Text = " 提示 ";
                panelSure.Visible = true;
                panelQuestion.Visible = false;
            }


            this.labMesTxt.Text = msg;

            SizeF size = TextRenderer.MeasureText(msg, new Font("微软雅黑", 10, FontStyle.Regular));
            int TempWidth = (int)size.Width;
            if (TempWidth <= 240) { return; }
            this.Width = (int)size.Width + 130;
            btnSure.Focus();
        }
    }
}
